<template>
    <div>
        <h1>科室修改</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>科室编号</td>
                    <td>
                        <input type="text" v-model="date.kHouseId">
                    </td>
                </tr>
                <tr>
                    <td>科室名称</td>
                    <td>
                        <input type="text" v-model="date.kHouseName">
                    </td>
                </tr>
                <tr>
                    <td>科室人数</td>
                    <td>
                        <input type="text" v-model="date.people">
                    </td>
                </tr>
                <tr>
                    <td>科室描述</td>
                    <td>
                        <textarea v-model="date.miaoshu"></textarea>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="修改" @click="add1">
                    </td>
                </tr>
            </tbody>
        </table>
        <a href="/Showk">返回科室显示列表</a>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter,useRoute } from 'vue-router';
const routher = useRouter()
const routhe = useRoute()
onMounted(()=>{
    upd()
})
const upd=()=>{
    var vid = routhe.query.id
    axios.get("/api/KHouse/FanHouse",{params:{id:vid}}).then(res=>{
        date.value=res.data
    })
}
const add1=()=>{
    if(date.value.kHouseName=="儿童儿儿科"){
        alert("科室不能重复")
        return
    }
    axios.put("/api/KHouse/UpdHouse",date.value).then(res=>{
        if(res.data>0){
            alert("修改成功")
            routher.push({path:"/Showk"})
        }
        else{
            alert("修改失败")
        }
    })
}
const date=ref({
  "kHouseId": 0,
  "kHouseName": "",
  "people": 0,
  "miaoshu": "",
  //"kTimes": "",
  //"isDelete": false
})
</script>

<style scoped>

</style>